// 文件上传

const { getUploadedUrl } = require('../utils/upload');

// 图片上传
const imgUpload = async (req, res) => {
    const output = {
        code: 200,
        msg: '操作成功'
    }
    const { file } = req;
    if (!file) {
        output.code = 500;
        output.msg = "操作失败";
        return res.send(output);
    }
    // 获取图片地址
    const imgUrl = getUploadedUrl(file);
    output.data = imgUrl;
    res.send(output);
}

module.exports = {
    imgUpload
}